package com.tarena.lbs.message.web.controller;

import com.tarena.lbs.base.protocol.exception.BusinessException;
import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.message.web.service.TriggerService;
import com.tarena.lbs.pojo.message.param.TriggerMsgTemplateInsertParam;
import com.tarena.lbs.pojo.message.vo.TriggerTemplateVO;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TriggerController {
    @Autowired
    private TriggerService triggerService;
    //查询所有触发模版
    @PostMapping("admin/message/triggerMsgTemplate/selectAll")
    public Result<List<TriggerTemplateVO>> selectTriggers(){
        List<TriggerTemplateVO> vos= triggerService.selectTriggers();
        return new Result<>(vos);
    }
    @PostMapping("/admin/message/triggerMsgTemplate/insert")
    public Result<Void> triggerTemplateSave(@RequestBody TriggerMsgTemplateInsertParam param) throws BusinessException {
        triggerService.triggerTemplateSave(param);
        return Result.success();
    }
}
